package nirvana.core.mybatis.configuration;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MybatisPlusConfiguration
 * note: you can inherit from this class to define your customized configuration for mybatis plus
 *
 * @author linkanyway
 * @version 1.0
 * @date 2022/04/15 21:14
 */
@Configuration
public class MybatisPlusConfiguration {


    /**
     * 配置 MBP 的插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor ();
        //add pagination plugin
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor (DbType.MYSQL);
        interceptor.addInnerInterceptor (paginationInnerInterceptor);
        return interceptor;
    }
}
